<template>
  <div style="height: 100%; width: 100%; position: relative">
      <div class="pagetop" ref="buttondiv">
          <div class="search-title">快速查找</div>
          <el-input style="width: 250px" v-model="searchtext" placeholder="报告单元、仪器、检验者、审核者、病人类别"></el-input>
          <div class="operation-list">
              <el-button @click="QueryData()" icon="el-icon-search" v-has="'PINQUERY'" type="primary">查询</el-button>
              <el-button @click="OpenDialog(1)" icon="el-icon-plus" v-has="'PADD'">新增</el-button>
              <el-button @click="OpenDialog(2)" icon="el-icon-edit" v-has="'PMODIFY'">修改</el-button>
              <el-button @click="DelSetting()" icon="el-icon-delete" v-has="'PDELETE'">删除</el-button>
          </div>
      </div>
      <div class="pagecenter">
          <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=250 :rememberConfig="false" :canDrag="false">
              <template v-slot:fix>
                  <div style="height:100%;">
                      <vxe-table :data="list" :loading="loading" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" @current-change="currentChangeEvent" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                          <vxe-table-column type="index" title="NO." width="40" align="center"></vxe-table-column>
                          <vxe-table-column field="rptunitname" title="报告单元" width="80"></vxe-table-column>
                          <vxe-table-column field="instrname" title="仪器" width="160"></vxe-table-column>
                          <vxe-table-column field="pat_typename" title="病人类别" width="150"></vxe-table-column>
                          <vxe-table-column field="checkusername" title="审核者" width="80"></vxe-table-column>
                          <vxe-table-column field="reportusername" title="检验者" width="80"></vxe-table-column>
                          <vxe-table-column field="checkmode" title="选择模式" width="120">
                              <template v-slot="{ row }">
                                  <span v-if="row.checkmode == '1'">审核模式</span>
                                  <span v-if="row.checkmode == '2'">仅判定</span>
                                  <span v-if="row.checkmode == '3'">签名模式</span>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="stopflag" title="是否停用" width="80" align="center">
                              <template v-slot="{ row }">
                                  <el-checkbox v-model="row.stopflag" true-label="1" false-label="0" :disabled="true"></el-checkbox>
                              </template>
                          </vxe-table-column>
                      </vxe-table>
                  </div>
              </template>
              <div style="height:100%;width:100%;">
                  <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=40 :rememberConfig="false" :canDrag="false">
                      <template v-slot:fix>
                          <div style="height:100%;">
                              <table width="100%">
                                  <tr>
                                      <td width="80px">日期：</td>
                                      <td width="200px">
                                          <el-date-picker type="date" placeholder="选择日期" v-model="createdate" value-format="yyyy-MM-dd" style="width: 100%;" @change="CreateDateChange"></el-date-picker>
                                      </td>
                                      <td width="80px">快速查找：</td>
                                      <td width="200px">
                                          <el-input style="width: 100%" v-model="searchreporttxt" placeholder="标本号、条码号、报告ID"></el-input>
                                      </td>
                                      <td></td>
                                      <td width="250px">
                                          <div style="">
                                              <span style="color:green;font-size:18px;font-weight:bold;" v-if="autocheckisrunningflag">后台自动审核运行中...</span>
                                              <span style="color:blue;font-size:18px;font-weight:bold;" v-else>后台自动审核已停止运行！</span>
                                          </div>
                                      </td>
                                      <td width="200px">
                                          <div style="">
                                              <el-button @click="StopRefresh()" :icon="refreshflag?'el-icon-video-pause':'el-icon-video-play'">{{refreshflag?'暂停自动刷新':'启动自动刷新'}}</el-button>
                                          </div>
                                      </td>
                                      <td>
                                          <rm-timer v-if="showtimeflag" v-slot="timeObj" :time="countDown">
                                              <div class="count-down">
                                                  <div class="icon"></div>
                                                   {{timeObj.ss}}秒
                                              </div>
                                          </rm-timer>
                                      </td>
                                  </tr>
                              </table>
                          </div>
                      </template>
                      <div style="height:100%;width:100%;">
                          <rm-layout-left splitcolor="white" movingcolor="#00ffff" :splitwidth=5 fixsize="50%" :minfixsize=80>
                              <template v-slot:fix>
                                  <div style="height:100%">
                                      <vxe-table show-overflow ref="xTable1" height="auto" :loading="reportloading" :cell-class-name="cellClassName" :sort-config="{trigger: 'cell'}" :data.sync="reportlist" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe @current-change="currentReportChangeEvent" header-align="center">
                                          <vxe-table-column field="createtime" title="创建时间" width="120" align="center"></vxe-table-column>
                                          <vxe-table-column field="chkresult" title="自动审核结果" width="160" align="center"></vxe-table-column>
                                          <vxe-table-column field="chktime" title="自动审核时间" width="120" align="center"></vxe-table-column>
                                          <vxe-table-column field="rptunitname" title="报告单元" width="100" align="center"></vxe-table-column>
                                          <vxe-table-column field="sampledate" title="标本日期" width="80" sortable :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                                          <vxe-table-column field="sampleno" title="标本编号" width="60" align="center"></vxe-table-column>
                                          <vxe-table-column field="barcode" title="条码号" width="80"></vxe-table-column>
                                          <vxe-table-column field="pat_typename" title="病人类别" width="60" align="center"></vxe-table-column>
                                          <vxe-table-column field="chkflag" title="自动审核标志" width="120" align="center">
                                              <template v-slot="{ row }">
                                                  <div v-if="row.chkflag == '1'" style="background-color:#67C23A;color: white">通过</div>
                                                  <div v-else-if="row.chkflag == '0'">待审核</div>
                                                  <div v-else-if="row.chkflag == '2'" style="background-color:#F56C6C;color: white">不通过</div>
                                                  <div v-else-if="row.chkflag == '9'" style="background-color:#F56C6C">不参与审核</div>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="reportid" title="报告ID" width="100"></vxe-table-column>
                                          <vxe-table-column field="rechk_dt" title="标本审核时间" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                                          <vxe-table-column field="rechk_username" title="审核者" width="60" align="center"></vxe-table-column>
                                          <vxe-table-column field="report_username" title="检验者" width="60" align="center"></vxe-table-column>
                                          <vxe-table-column field="req_deptno" title="申请科室" width="60" align="center"></vxe-table-column>
                                      </vxe-table>
                                      <template>
                                          <div style="overflow: hidden;position: absolute;right:20px;bottom: 20px;z-index: 1;width: 800px;">
                                              <div style="font-size: 20px; overflow: auto; text-align: right">
                                                  <span style="color: #67C23A; margin-left: 5px">已通过:{{ PassedNum }} </span>
                                                  <span style="color: #F56C6C; margin-left: 5px">不通过:{{ UnPassNum }} </span>
                                                  <span style="margin-left: 5px">待审核:{{ UnCheckNum }} </span>
                                                  <span style="color: red; margin-left: 5px">不参与审核:{{ UnPartNum }} </span>
                                                  <span style="color: blue; margin-left: 5px"> 总计:{{ TotalNum }}</span>
                                                  <span style="color: blue; margin-left: 5px">{{ NowNum }}/{{ TotalNum }}</span>
                                              </div>
                                          </div>
                                      </template>
                                  </div>
                              </template>
                              <div style="height:100%">
                                  <vxe-table :data.sync="ResultTableData" height="auto" highlight-current-row :loading="resultloading" highlight-hover-row highlight-hover-column resizable show-header-overflow="tooltip" border fit show-overflow="tooltip" header-align="center" size="mini" stripe ref="xTable2">
                                      <vxe-table-column type="index" title="NO." width="60" align="center"></vxe-table-column>
                                      <vxe-table-column field="rpt_itemname" sortable title="检验项目" width="220" show-overflow>
                                          <template v-slot="{ row }">
                                              <div v-if="row.alertflag == '1'" style="background:red;padding:0px 10px">{{ row.rpt_itemname }}</div>
                                              <div v-else style="padding:0px 10px">{{ row.rpt_itemname }}</div>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="result_str" sortable title="检测结果" width="80" show-overflow>
                                          <template v-slot="{ row }">
                                              <div :style="{background: row.cp_resultbackgroundcolor,color: row.cp_resultcolor}" style="padding:0px 10px">{{ row.result_str }}</div>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="result_unit" sortable title="单位" width="70" show-overflow></vxe-table-column>
                                      <vxe-table-column field="result_ref" sortable title="参考值" width="100" show-overflow></vxe-table-column>
                                      <vxe-table-column field="result1" :title="result1text" width="70px" v-if="result1 == 1"></vxe-table-column>
                                      <vxe-table-column field="result2" :title="result2text" width="70px" v-if="result2 == 1"></vxe-table-column>
                                      <vxe-table-column field="result3" :title="result3text" width="70px" v-if="result3 == 1"></vxe-table-column>
                                      <vxe-table-column field="result_txt" sortable title="大文本结果" width="130" show-overflow></vxe-table-column>
                                      <vxe-table-column field="instrid" sortable title="检验仪器" width="100" show-overflow></vxe-table-column>
                                      <vxe-table-column field="interno" sortable title="通道号" width="100" show-overflow></vxe-table-column>
                                      <vxe-table-column field="alertflag" align="center" sortable title="危急标志" width="60" show-overflow></vxe-table-column>
                                      <vxe-table-column field="result_flag" align="center" sortable title="结果标志" width="60" show-overflow></vxe-table-column>
                                      <vxe-table-column field="redo_flag" align="center" sortable title="复查标志" width="60" show-overflow></vxe-table-column>
                                      <vxe-table-column field="redo_result" sortable title="复查前结果" width="120" show-overflow></vxe-table-column>
                                      <vxe-table-column field="orig_result_num" sortable title="原始数值结果" width="120" show-overflow></vxe-table-column>
                                      <vxe-table-column field="orig_result_str" sortable title="原始文本结果" width="120" show-overflow></vxe-table-column>
                                      <vxe-table-column field="modify_flag" align="center" sortable title="修改标志" width="60" show-overflow></vxe-table-column>
                                      <vxe-table-column field="first_dt" align="center" ortable title="第一次填入时间" width="120" show-overflow></vxe-table-column>
                                      <vxe-table-column field="last_dt" align="center" sortable title="最后修改时间" width="120" show-overflow></vxe-table-column>
                                      <vxe-table-column field="last_user" align="center" sortable title="最后修改人" width="80" show-overflow></vxe-table-column>
                                      <vxe-table-column field="rptunitid" sortable title="报告单元" width="150" show-overflow></vxe-table-column>
                                      <vxe-table-column field="germflag" align="center" sortable title="细菌标志" width="60" show-overflow></vxe-table-column>
                                      <vxe-table-column field="orig_result_flag" align="center" sortable title="原始结果标志" width="160" show-overflow></vxe-table-column>
                                  </vxe-table>
                              </div>
                          </rm-layout-left>
                      </div>
                  </rm-layout-top>
              </div>
          </rm-layout-top>
      </div>
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" :title="dialogTitle" :visible.sync="dialogFormVisible" width="800px" height="500px" v-if="dialogFormVisible">
          <div>
              <el-form :inline="true" :model="SettingItem" @submit.native.prevent label-width="auto" ref="form">
                  <table height="100%" width="100%" style="width: 100%" class="tablelayout" ref="inputtable">
                      <tr>
                          <td align="right">报告单元</td>
                          <td>
                              <el-select v-model="SettingItem.rptunitid" @dblclick.native="popMultipleChk(SettingItem.rptunitid,'rptunitid',rptunitOption,'请选择报告单元')" filterable clearable style="width:100%" @change="rptunitchange" :disabled="actionflag == 2">
                                  <el-option v-for="(item,index) in rptunitOption" :key="index" :value="item.data" :label="item.display"></el-option>
                              </el-select>
                          </td>
                          <td align="right">病人类型</td>
                          <td>
                              <el-select v-model="SettingItem.pat_typecode" @dblclick.native="popMultipleChk(SettingItem.pat_typecode,'pat_typecode',pattypeOption,'病人类型选择')" filterable clearable style="width:100%">
                                  <el-option v-for="(item,index) in pattypeOption" :value="item.data" :label="item.display" :key="index"></el-option>
                              </el-select>
                          </td>
                          <td>审核者</td>
                          <td>
                              <el-input v-model="SettingItem.checkusername" style="width: 100%;" readonly @dblclick.native="LoginPage(1)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td align="right">仪器</td>
                          <td colspan="3">
                              <el-select v-model="SettingItem.instrid" @dblclick.native="popMultipleChk(SettingItem.instrid,'instrid',instrOption,'仪器选择')" filterable clearable style="width:100%" :disabled="actionflag == 2">
                                  <el-option v-for="(item,index) in instrOption" :value="item.data" :label="item.display" :key="index"></el-option>
                              </el-select>
                          </td>
                          <td>检验者</td>
                          <td>
                              <el-input v-model="SettingItem.reportusername" style="width: 100%;" readonly @dblclick.native="LoginPage(2)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3" style="vertical-align: top">
                              <el-radio-group v-model="SettingItem.checkmode" @change="RadioChange" style="padding-top: 5px">
                                  <el-radio label="1">审核模式</el-radio>
                                  <el-radio label="2">仅判定</el-radio>
                                  <el-radio label="3">签名模式</el-radio>
                              </el-radio-group>
                          </td>
                          <td colspan="3" style="padding-left: 100px;">
                              <el-checkbox v-show="actionflag == 2" v-model="SettingItem.stopflag" true-label="1" false-label="0">停用</el-checkbox>
                          </td>
                      </tr>
                  </table>
              </el-form>
              <div class="dialog-footer" slot="footer" style="text-align: right">
                  <table style="width: 100%">
                      <tr>
                          <td width="700" style="text-align:left;"><span style="color:blue;">新增时报告单元，仪器和病人类型都可双击多选</span></td>
                          <td>
                              <el-button @click="CommitTips()">确 定</el-button>
                          </td>
                          <td>
                              <el-button @click="CancelTips()">取 消</el-button>
                          </td>
                      </tr>
                  </table>
              </div>
          </div>
      </el-dialog>
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true" v-if="dialogMultipleVisible">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="提示" :visible.sync="dialogVisible" width="30%">
          <div class="el-message-box__status el-icon-warning"></div>
          <div class="el-message-box__message" style="padding-top: 24px">
              <p>
                  确定要删除报告单元-仪器:<b style="color: red">{{ DelName }}</b>吗?
              </p>
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button @click="DelCommitTips()">确 定</el-button>
              <el-button @click="DelCancelTips()">取 消</el-button>
          </span>
      </el-dialog>
  </div>
</template>

<script>
import XEUtils from "xe-utils";
import rmTimer from "@/components/rmcompents/rm_timer.vue";
export default {
  name: "LIS162",
  components: {
      rmTimer
  },
  data() {
      return {
          searchtext: "",
          SettingData: [],
          loading: false,
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          dialogTitle: "",
          dialogFormVisible: false,
          SettingItem: {},
          rptunitOption: [],
          pattypeOption: [],
          instrOption: [],
          dialogVisible: false,
          DelName: "",
          actionflag: 0,
          option1: [],
          option2: [],
          fieldname: "",
          multichktitle: "",
          dialogMultipleVisible: false,
          autocheckisrunningflag: false,
          refreshflag: false,
          createdate: XEUtils.toDateString(new Date(), "yyyy-MM-dd"),
          reportloading: false,
          ReportTableData: [],
          ResultTableData: [],
          result1text: "",
          result2text: "",
          result3text: "",
          result1: "",
          result2: "",
          result3: "",
          resultloading: false,
          searchreporttxt: "",
          PassedNum: 0,
          UnPassNum: 0,
          UnCheckNum: 0,
          UnPartNum: 0,
          NowNum: 0,
          TotalNum: 0,
          countDown: 0,
          showtimeflag: false,
      };
  },
  computed: {
      list() {
          let filterName = this.searchtext.trim();
          if (filterName) {
              let rest = this.SettingData.filter((item) => {
                  return item.rptunitname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || item.instrname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.pat_typename ? item.pat_typename.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || item.checkusername.toUpperCase().indexOf(filterName.toUpperCase()) > -1 ||  item.reportusername.toUpperCase().indexOf(filterName.toUpperCase()) > -1;
              });
              return rest;
          } else {
              return this.SettingData;
          }
      },
      reportlist() {
          let filterName = this.searchreporttxt.trim();
          if (filterName) {
              let rest = this.ReportTableData.filter((item) => {
                  return (item.sampleno ? item.sampleno.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.barcode ? item.barcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.reportid ? item.reportid.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
              });
              return rest;
          } else {
              return this.ReportTableData;
          }
      },
  },
  watch: {},
  created() {
      this.InitPage(); //初始化查询
  },
  mounted() {},
  updated() {},
  methods: {
      QueryData() {
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS162",
                  method: "post",
                  data: {
                      action: "querylist",
                  },
              })
              .then((res) => {
                  this.loading = false;
                  this.SettingData = res.dt;
                  if(this.SettingData.length > 0) {
                      this.$refs.xTable.setCurrentRow(this.SettingData[0]);
                      this.DelName = this.SettingData[0].rptunitname + '-' + this.SettingData[0].instrname;
                  }
              });
      },
      OpenDialog(type) {
          if (type == 1) {
              console.log("OpenDialog: " + type);
              this.dialogTitle = "新增后台自动审核设置";
              this.actionflag = type;
              this.SettingItem = {
                  rptunitid: "",
                  pat_typecode: "",
                  checkuser: "",
                  checkusername: "",
                  instrid: "",
                  reportuser: "",
                  reportusername: "",
                  checkmode: "1",
                  stopflag: "0",
              };
              this.dialogFormVisible = true;
          }
          if (type == 2) {
              if(this.SettingData.length == 0){
                  this.$message.warning("无可修改的数据！", "提示");
                  return;
              }
              this.dialogTitle = "修改后台自动审核设置";
              this.actionflag = type;
              this.ShowUpdate();
              this.dialogFormVisible = true;
          }
      },
      ShowUpdate() {
          var row = this.$refs.xTable.getCurrentRow();
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS162",
                  method: "post",
                  data: {
                      action: "queryforupdate",
                      rptunitid: row.rptunitid,
                      instrids: row.instrids,
                  },
              })
              .then((res) => {
                  if (res.dt.length > 0) {
                      this.SettingItem = res.dt[0];
                      this.instrOption = res.instrOption;
                      this.SettingItem.rptunitid = this.SettingItem.rptunitid+"";
                      this.SettingItem.instrid = this.SettingItem.instrids;
                  }
              });
      },
      DelSetting() {
          this.dialogVisible = true;
      },
      currentChangeEvent({ row }) {
          this.DelName = row.rptunitname + '-' + row.instrname;
      },
      InitPage() {
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS162",
                  method: "post",
                  data: {
                      action: "initpage"
                  }
              })
              .then(res => {
                  if (res && !res.hasOwnProperty("errcode")) {
                      this.rptunitOption = res.rptunitOption;
                      this.pattypeOption = res.pattypeOption;
                      this.autocheckisrunningflag = res.startautocheckinbackend == "1";
                      this.QueryData();
                  }
              });
      },
      InitInstr(rptunitid) {
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS162",
                  method: "post",
                  data: {
                      action: "initpage",
                      rptunitid: rptunitid
                  }
              })
              .then(res => {
                  if (res && !res.hasOwnProperty("errcode")) {
                      this.instrOption = res.instrOption;
                  }
              });
      },
      rptunitchange(val) {
          this.InitInstr(val);
      },
      popMultipleChk(e, fieldname, option, title) {
          if (fieldname == "instrid" && this.SettingItem.rptunitid == "") {
              this.$alert("请选择报告单元后再选择仪器!");
              return;
          }
          let temp = XEUtils.clone(option, true);
          this.option1 = [];
          this.option2 = [];
          if (e != "") {
              let k = e.split(",");
              k.forEach(item => {
                  let ndata = temp.find(m => m.data == item);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              });
              temp.forEach(item => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.fieldname = fieldname;
          this.multichktitle = title;
          this.dialogMultipleVisible = true;
      },
      LoginPage(type) {
          this.$rm_Login({
              type: "请输入工号和密码",
              modal: type ? false : true,
              btn: {
                  confirmBtnText: "确定",
                  cancelBtnText: "取消"
              }
          })
              .then(res => {
                  if (res.flag == "1") {
                      if (type == 1) {
                          this.SettingItem.checkusername = res.username;
                          this.SettingItem.checkuser = res.userid;
                      } else if (type == 2) {
                          this.SettingItem.reportusername = res.username;
                          this.SettingItem.reportuser = res.userid;
                      }
                  }
              })
              .catch(e => {
                  if (!type) {
                      let index = this.$parent.$refs.itemtags.tagsList.findIndex(m => m.name == "LIS162");
                      this.$parent.$refs.itemtags.tagsList.splice(index, 1);
                      this.$router.go(-1);
                  }
              });
      },
      RadioChange(val) {
          if (val == "1") this.$alert("符合自动审核规则的报告将被置为【已审核】状态，需要登录检验者和审核者", "提示"); //审核模式
          if (val == "2") this.$alert("仅判定自动审核规则是否通过，不会修改报告的状态", "提示"); //仅判定模式
          if (val == "3") this.$alert("符合自动审核规则的报告将被置为【已签名】状态，需要登录检验者", "提示"); //签名模式
      },
      CommitTips() {
          if (this.SettingItem.rptunitid != "" && this.SettingItem.instrid != "" && this.SettingItem.checkmode != "" && this.SettingItem.checkusername != "" && this.SettingItem.reportusername != "") {
              this.SaveData(this.actionflag);
          } else {
              this.$message.warning("报告单元、仪器、审核模式、检验者和审核者不能为空!");
          }
      },
      CancelTips() {
          this.dialogFormVisible = false;
      },
      closedialog(value, name) {
          if (value != "close") {
              this.SettingItem[name] = value;
              if (name == "rptunitid") this.rptunitchange(value);
          }
          this.dialogMultipleVisible = false;
      },
      DelCommitTips() {
          var row = this.$refs.xTable.getCurrentRow();
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS162",
                  method: "post",
                  data: {
                      action: "deletedata",
                      rptunitid: row.rptunitid,
                      instrids: row.instrids,
                  }
              })
              .then(res => {
                  if(res.flag == 1) {
                      this.$message.success("删除成功！");
                      this.QueryData();
                  } else {
                      this.$message.error("删除失败！" + res.msg);
                  }
                  this.dialogVisible = false;
              });

      },
      DelCancelTips() {
          this.dialogVisible = false;
      },
      SaveData(actionflag) {
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS162",
                  method: "post",
                  data: {
                      action: "savedata",
                      ...this.SettingItem,
                      type: actionflag,
                  }
              })
              .then(res => {
                  if(res.flag == 1) {
                      this.$message.success("保存成功！");
                      this.QueryData();
                  } else {
                      this.$message.error("保存失败！" + res.msg);
                  }
                  this.dialogFormVisible = false;
              });
      },
      CreateDateChange(){
          this.AutoAutoCheck();
      },
      StopRefresh() {
          this.refreshflag = !this.refreshflag;
          if(this.refreshflag){
              this.AutoAutoCheck();
          }else{
              this.countDown = 0;
              this.showtimeflag = false;
          }
      },
      cellClassName({ row, column }) {
          if (column.property == "redo_flag") {
              if (row.redo_flag == "1") {
                  return "col-yellow";
              } else {
                  return "";
              }
          } else if (column.property == "emer_flag") {
              if (row.emer_flag == "1") {
                  return "col-green";
              } else {
                  return "";
              }
          } else if (column.property == "warn_flag") {
              if (row.warn_flag == "1") {
                  console.log("row.warn_flag ", row.warn_flag);
                  return "col-red";
              } else {
                  return "";
              }
          }
      },
      currentReportChangeEvent({ row, rowIndex, column, columnIndex }, event) {
          this.NowNum = rowIndex+1;
          this.QueryResult(row);
      },
      AutoAutoCheck() {
          let that = this;
          this.showtimeflag = false;
          this.countDown = 0;
          this.AutoCheckTimeOut().finally(e => {
              //如果已启动自动刷新并且日期是今天则保持查询，否则就查一次
              let nowdate = XEUtils.toDateString(new Date(), "yyyy-MM-dd");
              if (this.refreshflag && this.createdate == nowdate) {
                  setTimeout(() => {
                      that.AutoAutoCheck();
                  }, 20000);
              }
          });
      },
      async AutoCheckTimeOut() {
          var rcnt = await this.$tool.request({ url: "LIS/LIS1/LIS162", method: "post", data: { action: "queryreportlist", createdate: this.createdate } });
          if (rcnt && rcnt.dt) {
              this.ReportTableData = rcnt.dt;
              let nowdate = XEUtils.toDateString(new Date(), "yyyy-MM-dd");
              //不是当天就不用计时器了，反正只刷一次
              if(this.refreshflag && this.createdate == nowdate){
                  this.showtimeflag = true;
                  this.countDown = 20;
              }
              this.NowNum = 1;
              this.TotalNum = this.ReportTableData.length;
              this.PassedNum = this.ReportTableData.filter(item => item.chkflag == "1").length;
              this.UnCheckNum = this.ReportTableData.filter(item => item.chkflag == "0").length;
              this.UnPartNum = this.ReportTableData.filter(item => item.chkflag == "9").length;
              this.UnPassNum = this.TotalNum - this.PassedNum - this.UnCheckNum - this.UnPartNum;
              this.autocheckisrunningflag = rcnt.startautocheckinbackend == "1";
          }
      },
      QueryResult(row) {
          this.resultloading = true;
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS162",
                  method: "post",
                  data: {
                      action: "queryresultlist",
                      reportid: row.reportid,
                      rptunitid: row.rptunitid
                  }
              })
              .then(res => {
                  if (res && res.errcode == "1") {
                      this.ResultTableData = res.rtn[0];
                      var resultText = JSON.parse(res.resultText);
                      this.result1text = resultText.result1text;
                      this.result2text = resultText.result2text;
                      this.result3text = resultText.result3text;
                      this.result1 = resultText.result1;
                      this.result2 = resultText.result2;
                      this.result3 = resultText.result3;
                      this.resultloading = false;
                  }
              })
              .catch(e => {
                  this.$message.error(e);
                  this.resultloading = false;
              });
      },
  },
};
</script>

<style scoped>
::v-deep .vxe-input--wrapper .vxe-input {
  height: auto;
  width: 200px;
  border-radius: 0px;
}
::v-deep .el-button--default.btn-custom-cancel {
  float: right !important;
  margin-left: 10px;
}
::v-deep .el-input.is-disabled .el-input__inner {
  background-color: #f5f7fa;
  /* border-color: #E4E7ED; */
  color: #000000;
  cursor: not-allowed;
}
.pagetop {
  width: 100%;
  height: 35px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  font-size: 12px;
  z-index: 99;
  overflow-x: auto;
  white-space: nowrap;
}
.operation-list {
  right: 5px;
  position: absolute;
  top: 5px;
  display: flex;
  align-items: center;
}
.search-title {
  margin: 0 5px 0 20px;
  font-size: 12px;
}
.pagecenter {
  position: absolute;
  top: 40px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  right: 805px;
  left: 0;
}

.middle-right {
  background-color: chartreuse;
  position: absolute;
  top: 0;
  bottom: 2px;
  width: 800px;
  right: 0px;
}

table tr td:nth-child(odd) {
  text-align: right;
  white-space: nowrap;
}
table tr td:nth-child(even) {
  text-align: left;
}
table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}
::v-deep .el-checkbox__inner::after {
  border: 2px solid #000000 !important;
  box-sizing: content-box;
  content: "";
  border-left: 0 !important;
  border-top: 0 !important;
  height: 7px;
  left: 4px;
  position: absolute;
  top: 1px;
  transform: rotate(45deg) scaleY(0);
  width: 3px;
  transition: transform 0.15s ease-in 0.05s;
  transform-origin: center;
}
::v-deep .el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #000000;
  cursor: not-allowed;
}
::v-deep  .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner + .el-input.is-disabled .el-input__inner {
  background-color: #ffffff !important;
}
::v-deep  tr.vxe-body--row.row-modify {
  color: blue !important;
}
::v-deep  tr.vxe-body--row.row-new {
  color: red !important;
}
.border-firstcard {
  height: 100%;
  overflow-y: auto;
}
.count-down {
  border: 1px dashed;
}
</style>
